package com.wf.day_0619.test3.jdk;


import com.wf.day_0619.test3.CalculatorService;
import com.wf.day_0619.test3.CalculatorServiceImpl;

import java.lang.reflect.Proxy;

/**
 * @author mpk
 * @since 2024/6/19 19:32:47
 */
public class Demo {
    public static void main(String[] args) {


        CalculatorService calculatorService = (CalculatorService) Proxy.newProxyInstance(CalculatorService.class.getClassLoader()
                ,
                new Class<?>[]{CalculatorService.class}
                ,
                new MyInvocationHandler(new CalculatorServiceImpl())
        );



        System.out.println(calculatorService.add(1, 2));
        System.out.println(calculatorService.sub(1, 2));
        System.out.println(calculatorService.mul(1, 2));
        System.out.println(calculatorService.div(1, 2));


    }


}
